/**
 *Author: guanpf 992093924@qq.om
 *Date: 2023-07-31 19:15:46
 *LastEditTime: 2023-11-02 20:26:08
 *LastEditors: guanpf
 *Description: 
 *FilePath: /ZCGL_WX/src/api/asset.js
 */
import request from './base'
import glConfig from '../utils/config'
import store from '../store'
let api = "/api"
let wsApi = "/wsApi"
let msgApi = "/msgApi"
if (process.env.NODE_ENV == 'production') {
  api = wsApi = msgApi = ''
}
function changeRowToFormData(obj) {
  const formData = new FormData();
  Object.keys(obj).forEach((key) => {
    if (obj[key] instanceof Array) {
      obj[key].forEach((item) => {
        formData.append(key, item);
      });
      return;
    }
    formData.append(key, obj[key]);
  });
  return formData;
}
const assetApi = {

  /*
    *资产管理
  */

  
   // 查询资产列表
   getAssetList(params) {
    return request({
      url: `${wsApi}/quickoffice/api/assetInfo/findSearchAll`,
      method: 'get',
      params
    })
  },
  
  // 资产新增
  assetAdd(data) {
    return request({
      url: `${wsApi}/quickoffice/api/assetInfo/add`,
      method: 'post',
      data: changeRowToFormData(data)
    })
  },

  // 资产修改
  assetUpdate(data) {
    return request({
      url: `${wsApi}/quickoffice/api/assetInfo/update`,
      method: 'post',
      data: changeRowToFormData(data)
    })
  },
  
  // 查询资产信息
  getAssetInfo(params) {
   return request({
     url: `${wsApi}/quickoffice/api/assetInfo/findOne`,
     method: 'get',
     params
   })
  },
  
  // 数字id查询资产信息
  getAssetDetail(params) {
   return request({
     url: `${wsApi}/quickoffice/api/assetInfo/findCodeDetail`,
     method: 'get',
     params
   })
  },
  
  // 查询资产变动记录
  getAssetRecord(params) {
   return request({
     url: `${wsApi}/quickoffice/api/assetRecord/findAssetAll`,
     method: 'get',
     params
   })
 },
  
 // 查询我借用的资产-用于获取待归还列表、接收借出列表
 findMyBorrowAll(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetOrder/findMyBorrowAll`,
    method: 'get',
    params
  })
},
// 
 // 查询接收借出列表
 findUnconfirmBorrowAll(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetOrder/findUnconfirmBorrowAll`,
    method: 'get',
    params
  })
},

 // 根据classId查询位置列表
 findClassPlace(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetClass/findClassPlace`,
    method: 'get',
    params
  })
},


 // 资产借出
 assetOrderLend(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetOrder/add`,
    method: 'post',
    data: changeRowToFormData(data)
  })
},

  
// 查询资产分类list
assetClass(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetClass/findAll`,
   method: 'get',
   params
 })
},

// 查询资产分类
assetClassTree(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetClass/findAllTree`,
   method: 'get',
   params
 })
},
  
// 查询资产摆放位置
findTenPlace() {
 return request({
   url: `${wsApi}/quickoffice/api/assetInfo/findTenPlace`,
   method: 'get'
 })
},

  
// 查询名称
findTenName() {
 return request({
   url: `${wsApi}/quickoffice/api/assetInfo/findTenName`,
   method: 'get'
 })
},
  
// 资产归还
giveBack(data) {
 return request({
   url: `${wsApi}/quickoffice/api/assetOrder/giveBack`,
   method: 'post',
   data:changeRowToFormData(data)
 })
},
  
// 资产转移
assetTransfer(data) {
 return request({
   url: `${wsApi}/quickoffice/api/assetTransfer/add`,
   method: 'post',
   data:changeRowToFormData(data)
 })
},

// 新增资产盘点
assetCheckAdd(data) {
 return request({
   url: `${wsApi}/quickoffice/api/assetCheck/add`,
   method: 'post',
   data:changeRowToFormData(data)
 })
},

  
// 查询所有盘点
assetCheckAll(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetCheck/findAll`,
   method: 'get',
   params
 })
},
  
// 查询已盘点列表
findReadAll(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetCheck/findReadAll`,
   method: 'get',
   params
 })
},
  
// 查询未盘点列表
findUnreadAll(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetCheck/findUnreadAll`,
   method: 'get',
   params
 })
},

// 提交资产盘点
assetCheckUpdate(data) {
 return request({
   url: `${wsApi}/quickoffice/api/assetCheck/update`,
   method: 'post',
   data:changeRowToFormData(data)
 })
},
  
// 查询借据单列表
findBorrowAll(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetOrder/findBorrowAll`,
   method: 'get',
   params
 })
},
  
// 查询借据单详情
findBorrowDetail(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetOrder/findOne`,
   method: 'get',
   params
 })
},

// 查询可转移的资产列表
findCanTransferAll(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetInfo/findCanTransferAll`,
   method: 'get',
   params
 })
},

// 查询未接收数量
findUnconfirmAsset() {
 return request({
   url: `${wsApi}/quickoffice/api/assetInfo/findUnconfirmAsset`,
   method: 'get'
 })
},

// 根据用户分页查询我提交的转出的记录
myFindAllOut() {
 return request({
   url: `${wsApi}/quickoffice/api/assetTransfer/findAllOut`,
   method: 'get'
 })
},



// 资产接收-转移
receiveTransfer(params) {
 return request({
   url: `${wsApi}/quickoffice/api/assetTransfer/findAll`,
   method: 'get',
   params
 })
},

// 分页查询待审批转移记录列表
findApproverAll(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTransfer/findApproverAll`,
    method: 'get',
    params
  })
 },

  
// 借用 确认
orderConfirm(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetOrder/orderConfirm`,
    method: 'post',
    data:changeRowToFormData(data)
  })
 },
  
 // 转移 确认
 transferConfirm(data) {
   return request({
     url: `${wsApi}/quickoffice/api/assetTransfer/confirm`,
     method: 'post',
     data:changeRowToFormData(data)
   })
  },

//  统计全院资产
statisicsAllAsset(params = {}) {
  return request({
    url: `${wsApi}/quickoffice/api/assetStatistics/statisicsAllAsset`,
    method: 'get',
    params
  })
 },

//  统计全院资产 参数 classId、page、pageSize
findClassAll(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetStatistics/findClassAll`,
    method: 'get',
    params
  })
 },

 //  资产品牌型号使用统计 classId、page、pageSize
 getStatisicsTags(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetStatistics/statisicsTags`,
    method: 'get',
    params
  })
 },

//  按年统计资产活跃度 参数year
statisicsYearActive(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetStatistics/statisicsYearActive`,
    method: 'get',
    params
  })
 },

//  资产前十榜
statisicsTopName () {
  return request({
    url: `${wsApi}/quickoffice/api/assetStatistics/statisicsTopName`,
    method: 'get'
  })
 },

 //  资产负责人前十榜
 statisicsTopUse () {
  return request({
    url: `${wsApi}/quickoffice/api/assetStatistics/statisicsTopUse`,
    method: 'get'
  })
 },

 //  查询tag
 getTagList (params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTag/findByClass`,
    method: 'get',
    params
  })
 },


 //  查询所有树形返回  ------资产类别
 getFindAllTree (params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetClass/findAllTree`,
    method: 'get',
    params
  })
 },

 // 修改  ------资产类别
 assetClassUpdate(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetClass/update`,
    method: 'post',
    data:changeRowToFormData(data)
  })
 },
 // 新增  ------资产类别
 assetClassAdd(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetClass/add`,
    method: 'post',
    data:changeRowToFormData(data)
  })
 },
 // 删除  ------资产类别
 assetClassRemove(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetClass/remove`,
    method: 'get',
    params
  })
 },

 // 根据父级分类查询，parentId为空返回顶级  ------资产类别
 assetClassFindAll(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetClass/findAll`,
    method: 'get',
    params
  })
 },

 // 新增  ------品牌
 assetTagAdd(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTag/add`,
    method: 'post',
    data:changeRowToFormData(data)
  })
 },

 // 修改  ------品牌
 assetTagUpdate(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTag/update`,
    method: 'post',
    data:changeRowToFormData(data)
  })
 },

 // 删除  ------品牌
 assetTagRemove(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTag/remove`,
    method: 'get',
    params
  })
 },
 // List  ------品牌
 assetTagfindAllByClass(params) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTag/findAllByClass`,
    method: 'get',
    params
  })
 },
  // 查询审批人
  findApprover(params) {
    return request({
      url: `${wsApi}/quickoffice/api/assetTransfer/findApprover`,
      method: 'get',
      params
    })
  },
  // 查询转移记录详情
  assetTransferFindOne(params) {
    return request({
      url: `${wsApi}/quickoffice/api/assetTransfer/findOne`,
      method: 'get',
      params
    })
  },

  // 审批
  approver(data) {
  return request({
    url: `${wsApi}/quickoffice/api/assetTransfer/approver`,
    method: 'post',
    data:changeRowToFormData(data)
  })
 },
 

}

export default assetApi;



